'use strict';


module.exports = app => {
  class HomeController extends app.Controller {
    * wechatimg() {
      console.log('____________');
      var mediaId=this.ctx.request.body.mediaId;
      var path=this.ctx.request.body.path;
      console.log(path);
      console.log('____________');
      const result =yield this.ctx.curl('http://file.api.weixin.qq.com/cgi-bin/media/get?access_token='+this.ctx.session.wechat.accessToken.accessToken+'&media_id='+mediaId);
      var uploadResult=yield this.ctx.oss.put(path,result.data);
      console.log(uploadResult.url);
      yield this.ctx.body={
        url:uploadResult.url
      };
    }
  }
  return HomeController;
};
